<?php

	class Backend_IndexController extends Zend_Controller_Action {
	
		public function init() {
			
			$am = new Model_Authentication();
			
			$this->view->action_name = $this->getRequest()->getActionName();
			$this->view->controller_name = $this->getRequest()->getControllername();
		
			// Logged
			if($am->isLoggued()){
				$user = $am->getlogguedInformations();
				$this->view->is_logged = true;
				$this->view->user = $user;
				
			// Not logged
			} else {
					
				$redirector = $this->_helper->getHelper('Redirector');
				$redirector->gotoRoute(array('module' => 'backend', 'controller' => 'user', 'action' => 'signin'));
				$this->view->is_logged = false;
			}
			
			$this->view->headLink()
					->appendStylesheet($this->_request->getBaseUrl().'/styles/commun.css')
					->appendStylesheet($this->_request->getBaseUrl().'/styles/template.css');
		
			// Ajax's call
		    $this->_helper->AjaxContext()
		         ->addActionContext('listing', 'html')
		         ->addActionContext('parent', 'html')
		         ->addActionContext('get', 'html')
		         ->addActionContext('modifyechelon', 'json')
		         ->initContext();
		    
		    $this->view->baseUrl = $this->_request->getBaseUrl();
			
			// change layout
            $layout = Zend_Layout::getMvcInstance();
			$layout->setLayout('layout_admin');
		}
		
		public function indexAction() {
			
			$this->view->headTitle('Hybrid Legacy - Administration');	
			
				$this->view->headLink()	->appendStylesheet($this->_request->getBaseUrl().'/styles/backend/index.css');
					
				$this->view->jQuery()
						->addJavascriptFile($this->view->baseUrl('/javascript/jquery/jquery.js'))
						->addJavascriptFile($this->view->baseUrl('/javascript/jquery/jquery.form.js'))
						->addJavascriptFile($this->view->baseUrl('/javascript/jquery/jquery.validation.js'))
						->addJavascriptFile($this->view->baseUrl('/javascript/jquery/jquery.validation.rules_custom.js'))
						->addJavascriptFile($this->view->baseUrl('/javascript/jquery/jquery.validation.messages_fr.js'));
			
		}
		
	}
?>
